package com.cxrj.zhsq.housePropertyManage.service.impl;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Service;

import com.cxrj.zhsq.housePropertyManage.dao.PropertyHouseMapper;
import com.cxrj.zhsq.housePropertyManage.dao.PropertyMemberMapper;
import com.cxrj.zhsq.housePropertyManage.dao.PropertyOwnerMapper;
import com.cxrj.zhsq.housePropertyManage.entity.PropertyHouse;
import com.cxrj.zhsq.housePropertyManage.service.HousePropertyService;
import com.cxrj.zhsq.propertyManage.dao.PropertyPaymentMapper;
import com.cxrj.zhsq.propertyManage.entity.PropertyPayment;
import com.cxrj.zhsq.utils.DateUtils;

@Service
public class HousePropertyServiceImpl implements HousePropertyService {
	@Resource
	private PropertyHouseMapper propertyHouseMapper;
	@Resource
	private PropertyMemberMapper propertyMemberMapper;
	@Resource
	private PropertyOwnerMapper propertyOwnerMapper;
	@Resource
	private PropertyPaymentMapper propertyPaymentMapper;

	@Override
	public Map<String, Object> insertHouseProperty(PropertyHouse propertyHouse,String[] houses, HttpServletRequest request) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			propertyHouse.setCommunityId((String)request.getSession().getAttribute("communityId"));
			propertyHouse.setCommunityName((String)request.getSession().getAttribute("communityName"));
			propertyHouse.setState("2");
			propertyHouse.setType("1");
			propertyHouse.setCreateTime(new Date());
			int layerNumber=propertyHouse.getLayerNumber();//每一栋层数
			int unitNum=Integer.valueOf(request.getParameter("unitNum"));//单元数
			if (!propertyHouse.getBuiltTimeStr().equals("")) {
				propertyHouse.setBuiltTime(new SimpleDateFormat("yyyy-MM-dd").parse(propertyHouse.getBuiltTimeStr()));
			}
			for(int i=0;i< unitNum;i++){//单元循环
				int unit=i+1;
				propertyHouse.setUnit(unit+"");
				for(int j=1;j<=layerNumber;j++){//层数循环
					String[] rooms=houses[i].split("[*]");//获取每一层房子参数
					for(int l=0;l<rooms.length;l++){
						String[] room=rooms[l].split("-");//每间房参数
						propertyHouse.setId(UUID.randomUUID().toString());
						propertyHouse.setDoorCard(j+"0"+room[0]);//门牌号
						propertyHouse.setHouseType(room[1]);//房型
						propertyHouse.setArea(room[2]);//面积
						propertyHouse.setPrice(room[3]);//价格
						propertyHouseMapper.insertSelective(propertyHouse);
					}
				}
			}
			resultMap.put("result", 1);
			
		} catch (ParseException e) {
			e.printStackTrace();
			resultMap.put("result", 0);
		}
		return resultMap;
	}

	@Override
	public Map<String, Object> selectHouseList(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> sqlMap = new HashMap<String, Object>();
		response.setContentType("text/html;charset=utf-8");
		// 数据起始位置
		String start = request.getParameter("offset");
		// 数据长度
		String length = request.getParameter("limit");
		sqlMap.put("start", Integer.parseInt(start));
		sqlMap.put("length", Integer.parseInt(length));
		sqlMap.put("communityId", request.getSession().getAttribute("communityId"));
		sqlMap.put("numberPeriods", request.getParameter("numberPeriods"));
		sqlMap.put("building", request.getParameter("building"));
		sqlMap.put("unit", request.getParameter("unit"));
		sqlMap.put("doorCard", request.getParameter("doorCard"));
		sqlMap.put("isPay", request.getParameter("isPay"));
		// 总记录数
		String recordsTotal = "0";
		// 获取数据库总记录数
		recordsTotal = propertyHouseMapper.selectByCount(sqlMap) + "";
		List<PropertyHouse> list = propertyHouseMapper.selectHouseList(sqlMap);

		resultMap.put("total", recordsTotal);
		resultMap.put("recordsFiltered", recordsTotal);
		resultMap.put("rows", list);
		return resultMap;
	}

	@Override
	public Map<String, Object> selectHouseById(String id) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		PropertyHouse house=propertyHouseMapper.selectByPrimaryKey(id);
		house.setBuiltTimeStr(DateUtils.format(house.getBuiltTime(),"yyyy-MM-dd"));
		resultMap.put("house", house);
		return resultMap;
	}

	@Override
	public Map<String, Object> updateHouseProperty(PropertyHouse propertyHouse) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> sqlMap=new HashMap<>();
		resultMap.put("result", 0);
		try {
			if (!propertyHouse.getBuiltTimeStr().equals("")) {
				propertyHouse.setBuiltTime(new SimpleDateFormat("yyyy-MM-dd").parse(propertyHouse.getBuiltTimeStr()));
			}
			PropertyHouse house=propertyHouseMapper.selectByPrimaryKey(propertyHouse.getId());
			if(!house.getNumberPeriods().equals(propertyHouse.getNumberPeriods()) || !house.getBuilding().equals(propertyHouse.getBuilding()) 
					|| !house.getUnit().equals(propertyHouse.getUnit()) || !house.getDoorCard().equals(propertyHouse.getDoorCard())){
				sqlMap.put("oldNumberPeriods", house.getNumberPeriods());
				sqlMap.put("oldBuilding", house.getBuilding());
				sqlMap.put("oldUnit", house.getUnit());
				sqlMap.put("oldDoorCard", house.getDoorCard());
				sqlMap.put("newNumberPeriods", propertyHouse.getNumberPeriods());
				sqlMap.put("newBuilding", propertyHouse.getBuilding());
				sqlMap.put("newUnit", propertyHouse.getUnit());
				sqlMap.put("newDoorCard", propertyHouse.getDoorCard());
				propertyOwnerMapper.updateHouseDetails(sqlMap);
				propertyMemberMapper.updateHouseDetails(sqlMap);
				
			}
			int a=propertyHouseMapper.updateByPrimaryKeySelective(propertyHouse);
			if(a>0){
				resultMap.put("result", a);
			}
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return resultMap;
	}

	@Override
	public Map<String, Object> deleteHouse(PropertyHouse propertyHouse) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("result", 0);
		int a=propertyHouseMapper.updateByPrimaryKeySelective(propertyHouse);
		if(a>0){
			resultMap.put("result", a);
		}
		return resultMap;
	}
	
	@Override
	public Map<String, Object> selectNumberPeriods(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> sqlMap=new HashMap<>();
		sqlMap.put("communityId", request.getSession().getAttribute("communityId"));
		List<String> numberPeriods=propertyHouseMapper.selectNumberPeriods(sqlMap);
		resultMap.put("numberPeriods", numberPeriods);
		return resultMap;
	}
	@Override
	public Map<String, Object> selectBuilding(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> sqlMap=new HashMap<>();
		sqlMap.put("communityId", request.getSession().getAttribute("communityId"));
		sqlMap.put("numberPeriods", request.getParameter("numberPeriods"));
		List<String> building=propertyHouseMapper.selectBuilding(sqlMap);
		resultMap.put("building", building);
		return resultMap;
	}

	@Override
	public Map<String, Object> selectUnit(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> sqlMap=new HashMap<>();
		sqlMap.put("communityId", request.getSession().getAttribute("communityId"));
		sqlMap.put("numberPeriods", request.getParameter("numberPeriods"));
		sqlMap.put("building", request.getParameter("building"));
		List<String> unit=propertyHouseMapper.selectUnit(sqlMap);
		resultMap.put("unit", unit);
		return resultMap;
	}

	@Override
	public Map<String, Object> selectDoorCard(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> sqlMap=new HashMap<>();
		sqlMap.put("communityId", request.getSession().getAttribute("communityId"));
		sqlMap.put("numberPeriods", request.getParameter("numberPeriods"));
		sqlMap.put("building", request.getParameter("building"));
		sqlMap.put("unit", request.getParameter("unit"));
		List<String> doorCard=propertyHouseMapper.selectDoorCard(sqlMap);
		resultMap.put("doorCard", doorCard);
		return resultMap;
	}


	@Override
	public Map<String, Object> selectCheckingBuilding(HttpServletRequest request, String numberPeriods,
			String building) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> sqlMap=new HashMap<>();
		sqlMap.put("communityId", request.getSession().getAttribute("communityId"));
		sqlMap.put("numberPeriods", numberPeriods);
		sqlMap.put("building", building);
		int a=propertyHouseMapper.selectCheckingBuilding(sqlMap);
		if(a>0){
			resultMap.put("result", 0);
		}else{
			resultMap.put("result", 1);
		}
		return resultMap;
	}

	@Override
	public Map<String, Object> insertHousePropertyOne(HttpServletRequest request,PropertyHouse propertyHouse) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("result", 0);
		try {
			propertyHouse.setId(UUID.randomUUID().toString());
			propertyHouse.setCommunityId((String)request.getSession().getAttribute("communityId"));
			propertyHouse.setCommunityName((String)request.getSession().getAttribute("communityName"));
			propertyHouse.setState("2");
			propertyHouse.setType("1");
			propertyHouse.setCreateTime(new Date());
			if (!propertyHouse.getBuiltTimeStr().equals("")) {
				propertyHouse.setBuiltTime(new SimpleDateFormat("yyyy-MM-dd").parse(propertyHouse.getBuiltTimeStr()));
			}
			int a=propertyHouseMapper.insertSelective(propertyHouse);
			if (a>0) {
				resultMap.put("result", 1);
			}
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return resultMap;
	}

	@Override
	public Map<String, Object> selectCheckingDoorCard(HttpServletRequest request, String numberPeriods, String building,
			String unit, String doorCard) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> sqlMap=new HashMap<>();
		sqlMap.put("communityId", request.getSession().getAttribute("communityId"));
		sqlMap.put("numberPeriods", numberPeriods);
		sqlMap.put("building", building);
		sqlMap.put("unit", unit);
		sqlMap.put("doorCard", doorCard);
		int a=propertyHouseMapper.selectCheckingDoorCard(sqlMap);
		if(a>0){
			resultMap.put("result", 0);
		}else{
			resultMap.put("result", 1);
		}
		return resultMap;
	}

	@Override
	public Map<String, Object> selectHouseData(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> sqlMap=new HashMap<>();
		sqlMap.put("communityId", request.getSession().getAttribute("communityId"));
		sqlMap.put("building", "");
		sqlMap.put("unit", "");
		List<String> numberPeriods=propertyHouseMapper.selectNumberPeriods(sqlMap);
		List<String> building=propertyHouseMapper.selectBuilding(sqlMap);
		List<String> unit=propertyHouseMapper.selectUnit(sqlMap);
		List<String> doorCard=propertyHouseMapper.selectDoorCard(sqlMap);
		resultMap.put("doorCard", doorCard);
		resultMap.put("numberPeriods", numberPeriods);
		resultMap.put("building", building);
		resultMap.put("unit", unit);
		return resultMap;
	}

	@Override
	public Map<String, Object> deleteByIds(String[] ids) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		propertyHouseMapper.updateByIds(ids);
		resultMap.put("result", 0);
		return resultMap;
	}

	@Override
	public Map<String, Object> selectByPayDetail(String id) throws ParseException {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Map<String, Object> sqlMap = new HashMap<String, Object>();
		List<Map<String, Object>> list1 = new ArrayList<Map<String,Object>>();
		List<Map<String, Object>> list2 = new ArrayList<Map<String,Object>>();
		List<Map<String, Object>> list3 = new ArrayList<Map<String,Object>>();
		List<Map<String, Object>> list4 = new ArrayList<Map<String,Object>>();
		Date date = new Date();
		Calendar calendar = Calendar.getInstance();//日历对象
        calendar.setTime(date);//设置当前日期
		PropertyHouse house = propertyHouseMapper.selectByPrimaryKey(id);
		sqlMap.put("code", "zfwyf");
		sqlMap.put("communityId", house.getCommunityId());
		PropertyPayment propertyPayment = propertyPaymentMapper.selectByCode(sqlMap);
		Integer year = calendar.get(Calendar.YEAR);
		Integer month = calendar.get(Calendar.MONTH) + 1;
		if(house.getS1() != null && !house.getS1().equals("")) {
			String s1 = house.getS1();
			Date s1Date = new SimpleDateFormat("yyyy-MM-dd").parse(s1 + "-01");
			Calendar s1Calendar = Calendar.getInstance();
			s1Calendar.setTime(s1Date);
			Integer s1Year = Integer.parseInt(s1.split("-")[0]);
			Integer s1Month = Integer.parseInt(s1.split("-")[1]);
			if(house.getS2() != null  && !house.getS2().equals("")) {
				String s2 = house.getS2();
				Date s2Date = new SimpleDateFormat("yyyy-MM-dd").parse(s2 + "-01");
				Calendar s2Calendar = Calendar.getInstance();
				s2Calendar.setTime(s2Date);
				Integer s2Year = Integer.parseInt(s2.split("-")[0]);
				Integer s2Month = Integer.parseInt(s2.split("-")[1]);
				if(s2Year.intValue() == year.intValue()) {
					if(s2Month.intValue() == month.intValue()) {
						for (int i = month + 1; i <= 12; i++) {
							Map<String, Object> map1 = new HashMap<String, Object>();
							map1.put("date", year + "-" + i);
							map1.put("isPay", "false");
							list1.add(map1);
						}
						for (int i = 1; i <= 12; i++) {
							Map<String, Object> map2 = new HashMap<String, Object>();
							Map<String, Object> map3 = new HashMap<String, Object>();
							map2.put("date", (year + 1) + "-" + i);
							map2.put("isPay", "false");
							map3.put("date", (year + 2) + "-" + i);
							map3.put("isPay", "false");
							list2.add(map2);
							list3.add(map3);
						}
					}else if(s2Month.intValue() < month.intValue()) {
						for (int i = month; i <= 12; i++) {
							Map<String, Object> map1 = new HashMap<String, Object>();
							map1.put("date", year + "-" + i);
							map1.put("isPay", "false");
							list1.add(map1);
						}
						for (int i = 1; i <= 12; i++) {
							Map<String, Object> map2 = new HashMap<String, Object>();
							Map<String, Object> map3 = new HashMap<String, Object>();
							map2.put("date", (year + 1) + "-" + i);
							map2.put("isPay", "false");
							map3.put("date", (year + 2) + "-" + i);
							map3.put("isPay", "false");
							list2.add(map2);
							list3.add(map3);
						}
						for (int i = s2Month + 1; i < month; i++) {
							Map<String, Object> map4 = new HashMap<String, Object>();
							map4.put("date", year + "-" + i);
							map4.put("isPay", "false");
							list4.add(map4);
						}
					} else if(s2Month.intValue() > month.intValue()) {
						Integer parm = 1;
						if(s1Year.intValue() == year) {
							parm = s1Month;
						}
						for (int i = parm; i <= s2Month; i++) {
							Map<String, Object> map1 = new HashMap<String, Object>();
							map1.put("date", year + "-" + i);
							map1.put("isPay", "true");
							list1.add(map1);
						}
						for (int i = s2Month + 1; i <= 12; i++) {
							Map<String, Object> map1 = new HashMap<String, Object>();
							map1.put("date", year + "-" + i);
							map1.put("isPay", "false");
							list1.add(map1);
						}
						for (int i = 1; i <= 12; i++) {
							Map<String, Object> map2 = new HashMap<String, Object>();
							Map<String, Object> map3 = new HashMap<String, Object>();
							map2.put("date", (year + 1) + "-" + i);
							map2.put("isPay", "false");
							map3.put("date", (year + 2) + "-" + i);
							map3.put("isPay", "false");
							list2.add(map2);
							list3.add(map3);
						}
					}
				} else if(s2Year.intValue() < year.intValue()) {
					for (int i = month; i <= 12; i++) {
						Map<String, Object> map1 = new HashMap<String, Object>();
						map1.put("date", year + "-" + i);
						map1.put("isPay", "false");
						list1.add(map1);
					}
					for (int i = 1; i <= 12; i++) {
						Map<String, Object> map2 = new HashMap<String, Object>();
						Map<String, Object> map3 = new HashMap<String, Object>();
						map2.put("date", (year + 1) + "-" + i);
						map2.put("isPay", "false");
						map3.put("date", (year + 2) + "-" + i);
						map3.put("isPay", "false");
						list2.add(map2);
						list3.add(map3);
					}
					for (int i = s2Month + 1; i <= 12; i++) {
						Map<String, Object> map4 = new HashMap<String, Object>();
						map4.put("date", s2Year + "-" + i);
						map4.put("isPay", "false");
						list4.add(map4);
					}
					if(year.intValue() - s2Year.intValue() > 1) {
						for (int i = 1; i < year - s2Year; i++) {
							for (int j = 1; j <= 12; i++) {
								Map<String, Object> map4 = new HashMap<String, Object>();
								map4.put("date", (s2Year + i) + "-" + j);
								map4.put("isPay", "false");
								list4.add(map4);
							}
						}
					}
					for (int i = 1; i < month; i++) {
						Map<String, Object> map4 = new HashMap<String, Object>();
						map4.put("date", year + "-" + i);
						map4.put("isPay", "false");
						list4.add(map4);
					}
				} else if (s2Year.intValue() > year.intValue()) {
					for (int i = month; i <= 12; i++) {
						Map<String, Object> map1 = new HashMap<String, Object>();
						map1.put("date", year + "-" + i);
						map1.put("isPay", "true");
						list1.add(map1);
					}
					if(s2Year.intValue() > (year.intValue() + 1)) {
						for (int i = 1; i <= 12; i++) {
							Map<String, Object> map2 = new HashMap<String, Object>();
							map2.put("date", (year + 1) + "-" + i);
							map2.put("isPay", "true");
							list2.add(map2);
						}
						for (int i = 1; i <= s2Month; i++) {
							Map<String, Object> map3 = new HashMap<String, Object>();
							map3.put("date", (year + 2) + "-" + i);
							map3.put("isPay", "true");
							list3.add(map3);
						}
						for (int i = s2Month + 1; i <= 12; i++) {
							Map<String, Object> map3 = new HashMap<String, Object>();
							map3.put("date", (year + 2) + "-" + i);
							map3.put("isPay", "false");
							list3.add(map3);
						}
					} else {
						for (int i = 1; i <= s2Month; i++) {
							Map<String, Object> map2 = new HashMap<String, Object>();
							map2.put("date", (year + 1) + "-" + i);
							map2.put("isPay", "true");
							list2.add(map2);
						}
						for (int i = s2Month + 1; i <= 12; i++) {
							Map<String, Object> map2 = new HashMap<String, Object>();
							map2.put("date", (year + 1) + "-" + i);
							map2.put("isPay", "false");
							list2.add(map2);
						}
						for (int i = 1; i <= 12; i++) {
							Map<String, Object> map3 = new HashMap<String, Object>();
							map3.put("date", (year + 2) + "-" + i);
							map3.put("isPay", "false");
							list3.add(map3);
						}
					}
				}
			}else {
				if(s1Year.intValue() == year.intValue()) {
					if(s1Month.intValue() == month.intValue()) {
						for (int i = s1Month; i <= 12; i++) {
							Map<String, Object> map1 = new HashMap<String, Object>();
							map1.put("date", year + "-" + i);
							map1.put("isPay", "false");
							list1.add(map1);
						}
						for (int i = 1; i <= 12; i++) {
							Map<String, Object> map2 = new HashMap<String, Object>();
							Map<String, Object> map3 = new HashMap<String, Object>();
							map2.put("date", (year + 1) + "-" + i);
							map2.put("isPay", "false");
							map3.put("date", (year + 2) + "-" + i);
							map3.put("isPay", "false");
							list2.add(map2);
							list3.add(map3);
						}
					} else if(s1Month.intValue() < month.intValue()) {
						for (int i = month; i <= 12; i++) {
							Map<String, Object> map1 = new HashMap<String, Object>();
							map1.put("date", year + "-" + i);
							map1.put("isPay", "false");
							list1.add(map1);
						}
						for (int i = 1; i <= 12; i++) {
							Map<String, Object> map2 = new HashMap<String, Object>();
							Map<String, Object> map3 = new HashMap<String, Object>();
							map2.put("date", (year + 1) + "-" + i);
							map2.put("isPay", "false");
							map3.put("date", (year + 2) + "-" + i);
							map3.put("isPay", "false");
							list2.add(map2);
							list3.add(map3);
						}
						for (int i = s1Month; i < month; i++) {
							Map<String, Object> map4 = new HashMap<String, Object>();
							map4.put("date", year + "-" + i);
							map4.put("isPay", "false");
							list4.add(map4);
						}
					} else if(s1Month.intValue() > month.intValue()) {
						for (int i = s1Month; i <= 12; i++) {
							Map<String, Object> map1 = new HashMap<String, Object>();
							map1.put("date", year + "-" + i);
							map1.put("isPay", "false");
							list1.add(map1);
						}
						for (int i = 1; i <= 12; i++) {
							Map<String, Object> map2 = new HashMap<String, Object>();
							Map<String, Object> map3 = new HashMap<String, Object>();
							map2.put("date", (year + 1) + "-" + i);
							map2.put("isPay", "false");
							map3.put("date", (year + 2) + "-" + i);
							map3.put("isPay", "false");
							list2.add(map2);
							list3.add(map3);
						}
					}
				} else if(s1Year.intValue() < year.intValue()) {
					for (int i = month; i <= 12; i++) {
						Map<String, Object> map1 = new HashMap<String, Object>();
						map1.put("date", year + "-" + i);
						map1.put("isPay", "false");
						list1.add(map1);
					}
					for (int i = 1; i <= 12; i++) {
						Map<String, Object> map2 = new HashMap<String, Object>();
						Map<String, Object> map3 = new HashMap<String, Object>();
						map2.put("date", (year + 1) + "-" + i);
						map2.put("isPay", "false");
						map3.put("date", (year + 2) + "-" + i);
						map3.put("isPay", "false");
						list2.add(map2);
						list3.add(map3);
					}
					for (int i = s1Month; i <= 12; i++) {
						Map<String, Object> map4 = new HashMap<String, Object>();
						map4.put("date", s1Year + "-" + i);
						map4.put("isPay", "false");
						list4.add(map4);
					}
					if(year.intValue() - s1Year.intValue() > 1) {
						for (int i = 1; i < year - s1Year; i++) {
							for (int j = 1; j <= 12; i++) {
								Map<String, Object> map4 = new HashMap<String, Object>();
								map4.put("date", (s1Year + i) + "-" + j);
								map4.put("isPay", "false");
								list4.add(map4);
							}
						}
					}
					for (int i = 1; i < month; i++) {
						Map<String, Object> map4 = new HashMap<String, Object>();
						map4.put("date", year + "-" + i);
						map4.put("isPay", "false");
						list4.add(map4);
					}
				} else if(s1Year.intValue() > year.intValue()) {
					resultMap.put("result", -3);
					return resultMap;
				}
			}
		}else {
			resultMap.put("result", -1);
			return resultMap;
		}
		resultMap.put("result", 1);
		resultMap.put("year1", year);
		resultMap.put("year2", year + 1);
		resultMap.put("year3", year + 2);
		resultMap.put("price", propertyPayment.getPrice());
		resultMap.put("list1", list1);
		resultMap.put("list2", list2);
		resultMap.put("list3", list3);
		resultMap.put("list4", list4);
		resultMap.put("house", house);
		return resultMap;
	}

	@Override
	public Map<String, Object> updateHouseState(PropertyHouse house, HttpServletRequest request) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("result", 0);
		int a=propertyHouseMapper.updateByPrimaryKeySelective(house);
		if(a>0){
			resultMap.put("result", a);
		}
		return resultMap;
	}
}
